The Gameboard SDK allows developers to track engagement via play events. These event support custom data via an extras field which is a Json string with the additional data.
Extra Example - Critical Hit
{
"eventLabel": "Critical Hit"
"userIds": ["jentacles"]
}
To send Play Events from a game running in an Android WebView the steps are as follows:
implementation "com.lastgameboard.sdk:gameboardlytics:0.0.6"
WebView myWebView = (WebView) findViewById(R.id.webview);
WebSettings webSettings = myWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webView.addJavascriptInterface(new GameboardlyticsWebInterface(this), "Gameboardlytics");
<input type="button" value="Send Play" onClick="sendPlayEvent(null)" />
<script type="text/javascript">
function sendPlayEvent(extras) {
Gameboardlytics.sendPlayEvent(extras);
}
</script>
The game session started/ended events are used to provide Gameboard a bit more information about the game. In this case the duration of a given game sessions. How a sessions is defined is up to the game itself but it is important to return the length of that session.
Call sendEvent from JavaScript to send a GAME_SESSION_STARTED event.
<input type="button" value="Send Play" onClick="sendPlayEvent(null)" />
<script type="text/javascript">
function sendGameSessionStartedEvent(extras) {
// TODO Track the time when the start was sent. This needs to be done by the Game developer
Gameboardlytics.sendPlayEvent("GAME_SESSION_STARTED", extras);
}
</script>
Call sendEvent from JavaScript to send a GAME_SESSION_ENDED event.
<input type="button" value="Send Play" onClick="sendPlayEvent(null)" />
<script type="text/javascript">
function sendGameSessionEndedEvent(extras) {
// TODO Track the time when the start was sent. This needs to be done by the Game developer
Gameboardlytics.sendPlayEvent("GAME_SESSION_ENDED", extras);
}
</script>
Note: In the case of the GAME_SESSION_ENDED event the extras sent must contain a property name secondsElapsed that contains the number of seconds the duration lasted.
Note 2: The extras passed need to be a string representation of a JSON object. In Javascript the easiest way would be to wrap your object in a stringify call.
The following events will be tracked by Gameboard about your game without any effort from you as a Creator: